home *** CD-ROM | disk | FTP | other *** search
/ Freelog 22 / freelog 22.iso / Prog / Djgpp / GPC2952B.ZIP / doc / gpc / docdemos / complexoperationsdemo.pas < prev    next >
Encoding:
Pascal/Delphi Source File  |  2001-02-09  |  1.2 KB  |  42 lines

  1. program ComplexOperationsDemo (Output);
  2.  
  3. var
  4.   z1, z2 : Complex;
  5.   Len, Angle : Real;
  6.  
  7. begin
  8.   z1 := Cmplx (2, 1);
  9.   WriteLn;
  10.   WriteLn ('Complex number z1 is: (', Re (z1) : 1, ',', Im (z1) : 1, ')');
  11.   WriteLn;
  12.   z2 := Conjugate(z1); { GPC extension }
  13.   WriteLn ('Conjugate of z1 is: (', Re (z2) : 1, ',', Im (z2) : 1, ')');
  14.   WriteLn;
  15.   Len   := Abs (z1);
  16.   Angle := Arg (z1);
  17.   WriteLn ('The polar representation of z1 is: Length=', Len : 1,
  18.            ', Angle=', Angle : 1);
  19.   WriteLn;
  20.   z2 := Polar (Len, Angle);
  21.   WriteLn ('Converting (Length, Angle) back to (x, y) gives: (',
  22.            Re (z2) : 1, ',', Im (z2) : 1, ')');
  23.   WriteLn;
  24.   WriteLn ('The following operations operate on the complex number z1');
  25.   WriteLn;
  26.   z2 := ArcTan (z1);
  27.   WriteLn ('arctan (z1) = (', Re (z2), ', ', Im (z2), ')');
  28.   WriteLn;
  29.   z2 := z1 ** 3.141;
  30.   WriteLn ('z1 ** 3.141 =', Re (z2), ', ', Im (z2), ')');
  31.   WriteLn;
  32.   z2 := Sin (z1);
  33.   WriteLn ('Sin (z1) = (', Re (z2), ', ', Im (z2), ')');
  34.   WriteLn ('(Cos, Ln, Exp, SqRt and Sqr exist also.)');
  35.   WriteLn;
  36.   z2 := z1 pow 8;
  37.   WriteLn ('z1 pow 8 = (', Re (z2), ', ', Im (z2), ')');
  38.   WriteLn;
  39.   z2 := z1 pow (-8);
  40.   WriteLn ('z1 pow (-8) = (', Re (z2), ', ', Im (z2), ')');
  41. end.
  42.